#!/usr/bin/env python

"""
tf_test_003_Variable.py
Variable usage as counter test example.
"""

__version__     = "1.0.0"
__author__      = "David Qiu"
__email__       = "david@davidqiu.com"
__website__     = "www.davidqiu.com"
__copyright__   = "Copyright (C) 2017, David Qiu. All rights reserved."


import tensorflow as tf
import numpy as np


if __name__ == '__main__':
  # definition
  counter = tf.Variable(0, name='counter')
  stepsize = tf.constant(1, name='stepsize')
  op_update = tf.assign(counter, tf.add(counter, stepsize))

  op_init = tf.initialize_all_variables()

  # execution
  with tf.Session() as sess:
    sess.run(op_init)
    print(sess.run(counter))

    for i in range(3):
      sess.run(op_update)
      print(sess.run(counter))


